package com.util;

import java.lang.reflect.Field;
import java.util.HashMap;
import java.util.Map;

public class BeanForEach {

    public static Map<String, Object> reflect(Object e) throws Exception{
        Map<String, Object> map = new HashMap<>();
        Class cls = e.getClass();
        Field[] fields = cls.getDeclaredFields();
        for(int i=0; i<fields.length; i++){
            Field f = fields[i];
            f.setAccessible(true);
            map.put(f.getName(), f.get(e));
        }
        return map;
    }
}
